//////////////////////////////////////////////////////////////
//
//  Description	: PDF2HTML/BMP software
//  Author	: verypdf.com Inc
//  Version	: Ver1.2
//  Platform	: Windows95/98/Me/NT/2000/XP
//  Environment	: Visual C++ 6.0
//  Date	: 2002/04/03
//
//  Copyright(C) 2000--2003 verypdf.com Inc
//      
//  Contact infomation:
//        http://www.verypdf.com/
//        support@verypdf.com
//
//  This program is shareware; you can redistribute and/or 
//  modify it under the terms of the GNU General Public License.
//  See the GNU General Public License for more details.
//
//               Portion base on Xpdf code
//         Copyright 1996-2003 Glyph && Cog, LLC
//////////////////////////////////////////////////////////////

#ifdef __GNUC__
#pragma implementation
#endif

#include "aconf.h"
#include <stddef.h>
#include "gmem.h"
#include "Object.h"
#include "Array.h"

//------------------------------------------------------------------------
// Array
//------------------------------------------------------------------------
Array::Array(XRef *xrefA) 
{
	xref = xrefA;
	elems = NULL;
	size = length = 0;
	ref = 1;
}

Array::~Array() 
{
	int i;
	
	for (i = 0; i < length; ++i)
		elems[i].free();
	gfree(elems);
}

void Array::add(Object *elem) 
{
	if (length + 1 > size) 
	{
		size += 8;
		elems = (Object *)grealloc(elems, size * sizeof(Object));
	}
	elems[length] = *elem;
	++length;
}

Object *Array::get(int i, Object *obj) 
{
	return elems[i].fetch(xref, obj);
}

Object *Array::getNF(int i, Object *obj) 
{
	return elems[i].copy(obj);
}
